<template>
  <div class="login-page">
    <div class="login-box">
      <div class="logo-box">
        <div class="right">
          <div class="sys-name">后台管理</div>
          <div class="sys-sub-name">欢迎您，尊敬的管理员</div>
        </div>
      </div>
      <div class="form-box">
        <div class="form-item">
          <img src="../assets/images/shouji.png" />
          <el-input v-model="userAccount" clearable placeholder="请输⼊账号" />
        </div>
        <div class="form-item">
          <img src="../assets/images/yanzhengma.png" />
          <el-input
            v-model="password"
            type="password"
            clearable
            show-password
            placeholder="请输⼊密码"
          />
        </div>
        <div class="submit-box" @click="loginFun">登录</div>
      </div>
    </div>
  </div>
</template>

<script setup>
// 页面的逻辑
import { loginService } from "@/apis/suser";
import router from "@/router";
import { setToken } from "@/utils/cookie";
import { ref } from "vue";

const userAccount = ref("");
const password = ref("");

//点击登录按钮
async function loginFun() {
  try {
    //调用suser.js中的登录方法
    const loginResult = await loginService(userAccount.value, password.value);
    console.log("loginResult: ", loginResult);
    //将token存储到Cookie中
    setToken(loginResult.data);
    //跳转到后台管理首页
    router.push("/layout/cuser");
  } catch (error) {
    console.log("error:", error);
  }

  // if (loginResult.data.code === 1000) {
  //   //登录成功
  //   // console.log(loginResult.data.code)
  // //将token存储到Cookie中
  // setToken(loginResult.data.data);
  // //跳转到后台管理首页
  // router.push("/system");
  // } else {
  //   console.log("登录失败");
  //   ElMessage.error(loginResult.data.msg);
  // }
}
</script>

<style lang="scss" scoped>

.login-page {
  width: 100vw;
  height: 100vh;
  position: relative;
  margin-top: -20px;
  margin-left: -10px;
  overflow: hidden;

  .login-box {
    
    width: 456px;
    height: 404px;
    background: #ffffff;
    box-shadow: 0px 0px 6px 0px rgba(156, 155, 155, 0.945);
    background-image: linear-gradient(to top, #f3e7e9 0%, #e3eeff 99%, #e3eeff 100%);
    border-radius: 10px;
    opacity: 0.9;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    padding: 0 72px;
    padding-top: 50px;

    .logo-box {
      display: flex;
      align-items: center;
      margin-bottom: 30px;
      img {
        width: 68px;
        height: 68px;
        margin-right: 16px;
      }
      .sys-name {
        height: 33px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 24px;
        color: #222222;
        line-height: 33px;
        margin-bottom: 13px;
      }
      .sys-sub-name {
        height: 22px;
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 16px;
        color: #222222;
        line-height: 22px;
      }
    }
    :deep(.form-box) {
      .submit-box {
        margin-top: 90px;
        width: 456px;
        height: 48px;
        background: #32c5ff;
        border-radius: 8px;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 16px;
        color: #ffffff;
        letter-spacing: 1px;

        &:hover {
          background: #60c6ee;
        }
      }
      .form-item {
        display: flex;
        align-items: center;
        width: 456px;
        height: 48px;
        background: #f8f8f8;
        border-radius: 8px;
        margin-bottom: 30px;
        position: relative;
        .code-btn-box {
          position: absolute;
          right: 0;
          width: 151px;
          height: 48px;
          background: #32c5ff;
          border-radius: 8px;
          top: 0;
          display: flex;
          align-items: center;
          justify-content: center;
          cursor: pointer;
          span {
            font-family: PingFangSC, PingFang SC;
            font-weight: 400;
            font-size: 16px;
            color: #ffffff;
          }
        }
        .error-tip {
          position: absolute;
          width: 140px;
          text-align: right;
          padding-right: 12px;
          height: 20px;
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 14px;
          color: #fd4c40;
          line-height: 20px;
          right: 0;
          &.bottom {
            right: 157px;
          }
        }
        .el-input {
          width: 380px;
          font-family: PingFangSC, PingFang SC;
          font-weight: 400;
          font-size: 16px;
          color: #222222;
        }
        .el-input__wrapper {
          border: none;
          box-shadow: none;
          background: transparent;
          width: 230px;
          padding-left: 0;
        }
        img {
          width: 24px;
          height: 24px;
          margin: 0 18px;
        }
      }
    }
   
  }
  &::after {
    position: absolute;
    top: 0;
    left: 0;
    height: 100vh;
    bottom: 0;
    right: 0;
    // background: rgba(255, 255, 255, 0.8);
    background-image: linear-gradient(
      to top,
      #f3e7e9 0%,
      #e3eeff 99%,
      #e3eeff 100%
    );
    z-index: 1;
    content: "";
  }
 
}
</style>
